<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Vote
 * @copyright  Copyright 2011 KEENONWEB LLC
 * @license    http://www.keenonweb.com/
 * @version    $Id: index.tpl 2011-03-09 01:11:30 idris $
 * @author     Idris
 */
?>

<?php if ($this->paginator->getTotalItemCount()): ?>

<h3 class="sep">
  <span><?php echo $this->translate('%s Votings', $this->subject->getTitle()); ?></span>
</h3>
<br />

<div class="kowcore-manage-container">
  <ul class="browse">
    <?php foreach( $this->paginator as $item ): ?>
    <li class="<?php echo $item->featured ? 'featured' : ''; ?>">
      <div class='photo'>
        <?php echo $this->htmlLink($item->getHref(), $this->itemPhoto($item, 'thumb.normal')); ?>
      </div>
      <div class='info'>
        <h3 class="title"><?php echo $this->htmlLink($item->getHref(), $item->getTitle()) ?></h3>

        <div class="clr"></div>
        <ul class="misc">
          <?php if ($item->category_id): ?>
          <li class="category"><?php echo $this->translate('Category: %s', $this->htmlLink($this->url(array('controller' => 'music', 'action' => 'manage', 'category' => $item->category_id), 'vote_general'), $item->category_name)); ?></li>
          <?php endif; ?>
          <?php if ($item->view_count): ?>
          <li class="views"><?php echo $this->translate(array('%s view', '%s views', $item->view_count), $item->view_count); ?></li>
          <?php endif; ?>
          <?php if ($item->participant_count): ?>
          <li class="participants"><?php echo $this->translate(array('%s participant', '%s participants', $item->participant_count), $item->participant_count); ?></li>
          <?php endif; ?>
          <?php if ($item->comment_count): ?>
          <li class="comments"><?php echo $this->translate(array('%s comment', '%s comments', $item->comment_count), $item->comment_count); ?></li>
          <?php endif; ?>
          <?php $likeCount = $item->likes()->getLikeCount(); if ($likeCount): ?>
          <li class="likes"><?php echo $this->translate(array('%s like', '%s likes', $likeCount), $likeCount); ?></li>
          <?php endif; ?>
          <?php if ($item->keywords): ?>
          <li class="tags"><?php echo $item->getTagLinks(); ?></li>
          <?php endif; ?>
        </ul>
        <?php if (!$item->isStarted(false) && $this->isSelf): ?>
        <p class='date options'>
          <?php echo $this->htmlLink($this->url(array('action' => 'edit', 'controller' => $item->type, 'challenge_id' => $item->getIdentity()), 'vote_general'), '', array('class' => 'edit')); ?>
          <?php echo $this->htmlLink($this->url(array('action' => 'delete', 'controller' => 'vote', 'format' => 'smoothbox', 'challenge_id' => $item->getIdentity()), 'vote_general'), '', array('class' => 'delete smoothbox')); ?>
        </p>
        <?php elseif ($item->isStarted(false)): ?>
        <p class='date'>
          <?php echo $this->translate('Voting started'); ?>
        </p>
        <?php endif; ?>
        <div class="clr"></div>
        <p class='blurb'>
          <?php
                echo substr(strip_tags($item->getDescription()), 0, 350);
          if (strlen($item->getDescription())>349) echo "...";
          ?>
        </p>

        <p class="duration"><?php echo $this->translate('Started at %s lasts to %s', $this->timestamp(strtotime($item->starttime)), $this->timestamp(strtotime($item->endtime))); ?></p>

        <div class="clr"></div>
      </div>
      <div class="clr"></div>
    </li>
    <?php endforeach; ?>
  </ul>
  <div class="clr"></div>
</div>
<br />

<?php endif; ?>

<?php if ($this->partPaginator->getTotalItemCount()): ?>

<h3 class="sep">
  <span><?php echo $this->translate('%s Voting Participation', $this->subject->getTitle()); ?></span>
</h3>
<br />

<div class="kowcore-widget">
  
  <?php foreach( $this->partPaginator as $item ): ?>
    <?php echo $this->partial('widget/item.tpl', 'vote', array('item' => $item)); ?>
  <?php endforeach; ?>

  <div class="clr"></div>
</div>

<?php endif; ?>